module Alglib
    # Retrieves Pearson correlation for two arrays
    def self.pearson_correlation(a,b)
        raise ArgumentError "argument should be the same size" if a.size!=b.size
        Alglib_ext::pearsoncorrelation(a,b,a.size)
    end
    # Retrieves Spearman ranked correlation for two arrays
    # Equal to Pearson correlation for ranked data

    def self.spearman_correlation(a,b)
        raise ArgumentError "argument should be the same size" if a.size!=b.size
        Alglib_ext::spearmanrankcorrelation(a,b,a.size)
    end
    # Retrieves significance for pearson correlation for one or two tails
    # Returns a hash with keys :both, :left and :right
    def self.pearson_correlation_significance(r,size)
        out={}
        out[:both], out[:left], out[:right] = Alglib_ext::pearsoncorrelationsignificance(r, size)
        out
    end
    def self.spearman_correlation_significance(r,size)
        out={}
        out[:both], out[:left], out[:right] = Alglib_ext::spearmanrankcorrelationsignificance(r, size)
        out
    end
end
